home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 24 / Mac Magazin and MacEasy Magazine CD - Issue 24.iso / Wissenschaft & Technik / Sys Environment (PPC) Dev ƒ / Source / machineEnvConstructor.cpp next >
C/C++ Source or Header  |  1996-07-15  |  2KB  |  79 lines

  1. //machineEnvConstructor.cpp ©1996 Brian Bergstrand 07/16/96
  2.  
  3. //headers
  4. #include "sysEnv.h"
  5. #include "systems.h"
  6.  
  7. //constructor for Class MachineEnv
  8. MachineEnv::MachineEnv ()//define the constructor
  9. {
  10.   OSErr myErr;
  11.   long response, update, machine, proc, ram, logicalRam;
  12.   
  13.   /*If making a global variable of the class, uncomment the following
  14.     error checking code, and substitute in the correct constants for your 
  15.     resource ID's. 
  16.     This is because global class variables get intialized 
  17.     even before main() is called. Otherwise, you can check for Gestalt in your
  18.     own code.*/
  19.   /*
  20.   //test for gestalt, don't really need to do this, but Apple still recommends it
  21.   myErr = Gestalt (gestaltVersion, &response);
  22.   if (myErr)//if gestalt is not present
  23.   {
  24.     ExitToShell();//just exit
  25.   }
  26.   */
  27.   
  28.   myErr = Gestalt (gestaltSystemVersion, &response);//query for system version
  29.   if (myErr == noErr)//if there was not an error
  30.   {
  31.     sysVer = response;//set the system version
  32.     if (response>=_753)//if the system is 7.5.3 or greater, check for an update
  33.     {
  34.       myErr = Gestalt ('sysu', &update);
  35.       if (myErr == noErr)//if there was not an error
  36.         updateVer = update;//set the update version
  37.       else//if there was a problem or no update is available 
  38.         updateVer = false;//make sure we give it a value, or we crash
  39.     }    
  40.   }
  41.   else//if there was a problem make sure we give it a value, or we crash
  42.     sysVer = 0;
  43.     
  44.   //the rest of these follow the same format as above, so substitute comments in
  45.   myErr = Gestalt (gestaltMachineType, &machine);
  46.   if (myErr == noErr)
  47.     machineType = machine;
  48.   else
  49.     machineType = 0;
  50.   
  51.   myErr = Gestalt (gestaltNativeCPUtype, &proc);
  52.   if (myErr == noErr)
  53.     processor = proc;
  54.   else
  55.     processor = 0;  
  56.     
  57.   myErr = Gestalt (gestaltPhysicalRAMSize, &ram);
  58.   if (myErr == noErr)
  59.     realMem = ram;
  60.   else
  61.     realMem = 0;
  62.       
  63.   myErr = Gestalt (gestaltLogicalRAMSize, &logicalRam);
  64.   if (myErr == noErr)
  65.     logicalMem = logicalRam;
  66.   else
  67.     logicalMem = 0;
  68.     
  69.   myErr = Gestalt (gestaltVMAttr, &response);//check for VM
  70.   if (myErr == noErr)
  71.   {
  72.     if (response == gestaltVMPresent)//is VM present
  73.       VMon = true;
  74.     else
  75.       VMon = false;
  76.   }
  77.   else
  78.     VMon = false;                 
  79. }